define([ "app", "jquery", "md5", "ecb","artDialog","iframeTools", "ajaxfileupload", "services/UserService","services/TipsService",
		"directives/AudioPlayer",
		"resources/company/CompanyResource", 
		"resources/UserResource", "resources/ShareResource" ],
		function(app) {
			var deps = [ "$scope", "$state","$sce", "$timeout", "$window", "$location", "$stateParams","TipsService", "UserService", "UserResource", "ShareResource","CompanyResource" ];

			function controller($scope, $state,$sce,$timeout, $window, $location, $stateParams,TipsService, UserService, UserResource, ShareResource,CompanyResource) {
				
				$scope.companyVo={};
				/**
				 * 上传营业执照
				 */
				$scope.uploadPic =function (type){
					$("#chooseFile").trigger("click"); 
				}

				/**
				 * 取消
				 */
				$scope.comeback =function (){
					$state.go("home.accountManagement");
				}

				
				/**
				 * 保存办公环境
				 */
				$scope.saveCompanyPic= function(){
					var obj =$scope.companyVo;
					CompanyResource.saveCompanyPic(obj).success(function(data){
						$state.go('home.accountManagement');
		            });
		        };
				
		        $scope.count=0;
				$scope.change =function(fileObj){
					if($scope.count>6){
						alert("超过上传限制");
						return;
					}
					$.ajaxFileUpload({
						url : "restful/company/uploadFile",
						secureuri : false,// 一般设置为false
						fileElementId : "chooseFile",// 文件上传表单的id <input type="file" id="fileUpload" name="file" />
						dataType : 'json',// 返回值类型 一般设置为json
						type: 'post',
						data: {'type': 1},
						success : function(data) // 服务器成功响应处理函数
						{
							// 存储url值 
							$scope.count=$scope.count+1;
							var companyUrls=$scope.companyVo.companyUrls;
							if(companyUrls==null || companyUrls ==""){
								$scope.companyVo.companyUrls=data.obj;
							}else{
								$scope.companyVo.companyUrls=companyUrls+","+data.obj;
							}
							var html="";
							if($scope.count==1){
							    html ="<td style=\"padding-left: 12px;padding-top: 12px\"><img src=\"\" id=\"identificationCardback"+$scope.count+"\"  style=\"cursor: pointer;width: 151px;height: 150px;\"></td>";
							}else{
							    html ="<td style=\"padding-left: 12px;padding-top: 12px\"><img src=\"\" id=\"identificationCardback"+$scope.count+"\"  style=\"cursor: pointer;width: 151px;height: 150px;\"></td>";
							}
							$("#appendUrl").append(html);
							
							$("#identificationCardback"+$scope.count).attr('src',"http://image.radzp.com/"+data.obj); 
						},
						error : function(data)// 服务器响应失败处理函数
						{
							console.log("服务器异常");
						}
					});
					return false;
				}
				
			}
			controller.$inject = deps;
			return app.lazy.controller("UploadCompanyPictureController", controller);
		});
